Ext.define('app.SelectWindow',{	
	  extend:'Ext.Window',  
	  dataPanel:null,
	  constructor: function(config) {	
		    config.items = [];
			config = Ext.apply({
				width: app.checkWidth(config.width),
			    height:app.checkHeight(config.height),
			    layout:'fit',
			    modal:true
		    }, config);		
			this.callParent(arguments);		
	  },
	  initComponent:function(){
		  this.items = [this.dataPanel];
		  
		  this.buttons = [
		                  {
		                	  text:appLang.ADD,
		                	  scope:this,
		                	  handler:this.selectItem
		                  },{
		                	  text:appLang.CLOSE,
		                	  scope:this,
		                	  handler:this.close
		                  }
		             
		  ];

		  this.callParent(arguments);
		  
		  this.addEvents(
		            /**
		             * @event addItemCall
		             * @param record
		             */
		           'itemSelected'
		   ); 
		  
		  this.dataPanel.dataGrid.on('itemdblclick' ,function(view , record , number , event , options){
					this.sendSelected(record);
		 },this);
	  },
	  sendSelected:function(record){
		  this.fireEvent('itemSelected',record);
		  this.getEl().mask('Item selected');
		  var me = this;
		  setTimeout(function(){
			 me.getEl().unmask(); 
		  },600);
	  },
	  selectItem:function(){
		  var sm = this.dataPanel.dataGrid.getSelectionModel();
		  if(!sm.hasSelection()){
			  Ext.MessageBox.alert(appLang.MESSAGE,appLang.MSG_SELECT_ITEM_FOR_ADDING);
			  return;
		  }
		  this.sendSelected(sm.getSelection()[0]);
	  }
});

